.class Lcom/tendcloud/tenddata/du;
.super Ljava/lang/Object;


# static fields
.field private static final a:Ljava/lang/String; = "PushLog"

.field private static b:Lcom/tendcloud/tenddata/du;


# instance fields
.field private c:Landroid/content/Context;

.field private d:Landroid/net/LocalServerSocket;

.field private e:Lcom/tendcloud/tenddata/cx;

.field private f:Ljava/util/concurrent/BlockingQueue;

.field private g:Landroid/os/Handler;

.field private h:Z


# direct methods
.method static constructor <clinit>()V
    .locals 1

    const/4 v0, 0x0

    sput-object v0, Lcom/tendcloud/tenddata/du;->b:Lcom/tendcloud/tenddata/du;

    return-void
.end method

.method private constructor <init>(Landroid/content/Context;)V
    .locals 2

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    new-instance v0, Landroid/os/Handler;

    invoke-direct {v0}, Landroid/os/Handler;-><init>()V

    iput-object v0, p0, Lcom/tendcloud/tenddata/du;->g:Landroid/os/Handler;

    iput-object p1, p0, Lcom/tendcloud/tenddata/du;->c:Landroid/content/Context;

    invoke-static {p1}, Lcom/tendcloud/tenddata/cv;->a(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v0

    new-instance v1, Lcom/tendcloud/tenddata/dv;

    invoke-direct {v1, p0, p1}, Lcom/tendcloud/tenddata/dv;-><init>(Lcom/tendcloud/tenddata/du;Landroid/content/Context;)V

    invoke-static {v0, p1, v1}, Lcom/tendcloud/tenddata/cx;->a(Ljava/lang/String;Landroid/content/Context;Lcom/tendcloud/tenddata/cx$a;)Lcom/tendcloud/tenddata/cx;

    move-result-object v0

    iput-object v0, p0, Lcom/tendcloud/tenddata/du;->e:Lcom/tendcloud/tenddata/cx;

    new-instance v0, Ljava/util/concurrent/LinkedBlockingQueue;

    const/4 v1, 0x1

    invoke-direct {v0, v1}, Ljava/util/concurrent/LinkedBlockingQueue;-><init>(I)V

    iput-object v0, p0, Lcom/tendcloud/tenddata/du;->f:Ljava/util/concurrent/BlockingQueue;

    new-instance v0, Ljava/lang/Thread;

    new-instance v1, Lcom/tendcloud/tenddata/dw;

    invoke-direct {v1, p0}, Lcom/tendcloud/tenddata/dw;-><init>(Lcom/tendcloud/tenddata/du;)V

    invoke-direct {v0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    invoke-virtual {v0}, Ljava/lang/Thread;->start()V

    return-void
.end method

.method static declared-synchronized a(Landroid/content/Context;)Lcom/tendcloud/tenddata/du;
    .locals 2

    const-class v1, Lcom/tendcloud/tenddata/du;

    monitor-enter v1

    :try_start_0
    sget-object v0, Lcom/tendcloud/tenddata/du;->b:Lcom/tendcloud/tenddata/du;

    if-nez v0, :cond_0

    new-instance v0, Lcom/tendcloud/tenddata/du;

    invoke-direct {v0, p0}, Lcom/tendcloud/tenddata/du;-><init>(Landroid/content/Context;)V

    sput-object v0, Lcom/tendcloud/tenddata/du;->b:Lcom/tendcloud/tenddata/du;

    :cond_0
    sget-object v0, Lcom/tendcloud/tenddata/du;->b:Lcom/tendcloud/tenddata/du;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    monitor-exit v1

    return-object v0

    :catchall_0
    move-exception v0

    monitor-exit v1

    throw v0
.end method

.method static synthetic a(Lcom/tendcloud/tenddata/du;)Ljava/util/concurrent/BlockingQueue;
    .locals 1

    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->f:Ljava/util/concurrent/BlockingQueue;

    return-object v0
.end method

.method static synthetic b(Lcom/tendcloud/tenddata/du;)Lcom/tendcloud/tenddata/cx;
    .locals 1

    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->e:Lcom/tendcloud/tenddata/cx;

    return-object v0
.end method

.method static synthetic c(Lcom/tendcloud/tenddata/du;)Landroid/content/Context;
    .locals 1

    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->c:Landroid/content/Context;

    return-object v0
.end method

.method static synthetic d(Lcom/tendcloud/tenddata/du;)Z
    .locals 1

    iget-boolean v0, p0, Lcom/tendcloud/tenddata/du;->h:Z

    return v0
.end method


# virtual methods
.method public declared-synchronized a()Z
    .locals 7

    const/4 v1, 0x0

    const/4 v4, 0x0

    monitor-enter p0

    :try_start_0
    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->c:Landroid/content/Context;

    invoke-static {v0}, Lcom/tendcloud/tenddata/cv;->e(Landroid/content/Context;)Ljava/util/List;

    move-result-object v5

    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->c:Landroid/content/Context;

    const-string v2, ""

    invoke-static {v0, v2}, Lcom/tendcloud/tenddata/cz;->a(Landroid/content/Context;Ljava/lang/String;)I

    move-result v3

    invoke-interface {v5}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v6

    :cond_0
    :goto_0
    invoke-interface {v6}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_1

    invoke-interface {v6}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/String;

    iget-object v2, p0, Lcom/tendcloud/tenddata/du;->c:Landroid/content/Context;

    invoke-static {v2, v0}, Lcom/tendcloud/tenddata/cz;->a(Landroid/content/Context;Ljava/lang/String;)I

    move-result v2

    if-eqz v2, :cond_0

    if-le v2, v3, :cond_4

    move v1, v2

    :goto_1
    move v3, v1

    move-object v1, v0

    goto :goto_0

    :cond_1
    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->d:Landroid/net/LocalServerSocket;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-eqz v0, :cond_2

    if-eqz v1, :cond_2

    :try_start_1
    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->d:Landroid/net/LocalServerSocket;

    invoke-virtual {v0}, Landroid/net/LocalServerSocket;->close()V

    const/4 v0, 0x0

    iput-object v0, p0, Lcom/tendcloud/tenddata/du;->d:Landroid/net/LocalServerSocket;

    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/tendcloud/tenddata/du;->h:Z
    :try_end_1
    .catch Ljava/lang/Throwable; {:try_start_1 .. :try_end_1} :catch_0
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    :cond_2
    :goto_2
    if-eqz v1, :cond_3

    const/4 v0, 0x1

    :try_start_2
    iget-object v2, p0, Lcom/tendcloud/tenddata/du;->c:Landroid/content/Context;

    invoke-static {v2, v1}, Lcom/tendcloud/tenddata/cv;->d(Landroid/content/Context;Ljava/lang/String;)V

    :goto_3
    iget-object v2, p0, Lcom/tendcloud/tenddata/du;->g:Landroid/os/Handler;

    new-instance v3, Lcom/tendcloud/tenddata/dx;

    invoke-direct {v3, p0, v5, v1}, Lcom/tendcloud/tenddata/dx;-><init>(Lcom/tendcloud/tenddata/du;Ljava/util/List;Ljava/lang/String;)V

    const-wide/16 v4, 0xc8

    invoke-virtual {v2, v3, v4, v5}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    monitor-exit p0

    return v0

    :catch_0
    move-exception v0

    :try_start_3
    const-string v2, "PushLog"

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v6, "release global lock err: "

    invoke-virtual {v3, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v0}, Ljava/lang/Throwable;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v2, v0}, Lcom/tendcloud/tenddata/cs;->e(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    goto :goto_2

    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0

    :cond_3
    move v0, v4

    goto :goto_3

    :cond_4
    move-object v0, v1

    move v1, v3

    goto :goto_1
.end method

.method public declared-synchronized b()V
    .locals 3

    monitor-enter p0

    :try_start_0
    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->d:Landroid/net/LocalServerSocket;

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->d:Landroid/net/LocalServerSocket;

    invoke-virtual {v0}, Landroid/net/LocalServerSocket;->close()V

    const/4 v0, 0x0

    iput-object v0, p0, Lcom/tendcloud/tenddata/du;->d:Landroid/net/LocalServerSocket;

    :cond_0
    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->e:Lcom/tendcloud/tenddata/cx;

    invoke-virtual {v0}, Lcom/tendcloud/tenddata/cx;->c()V

    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/tendcloud/tenddata/du;->h:Z
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    :goto_0
    monitor-exit p0

    return-void

    :catch_0
    move-exception v0

    :try_start_1
    const-string v1, "PushLog"

    const-string v2, "stop global lock err: "

    invoke-static {v1, v2, v0}, Lcom/tendcloud/tenddata/cs;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method public declared-synchronized initPushSDK(Landroid/content/Intent;)V
    .locals 4

    monitor-enter p0

    if-eqz p1, :cond_0

    :try_start_0
    const-string v0, "service-cmd"

    invoke-virtual {p1, v0}, Landroid/content/Intent;->getStringExtra(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    if-eqz v0, :cond_1

    const-string v1, "service-ping"

    invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_1

    iget-object v1, p0, Lcom/tendcloud/tenddata/du;->f:Ljava/util/concurrent/BlockingQueue;

    invoke-interface {v1, v0}, Ljava/util/concurrent/BlockingQueue;->offer(Ljava/lang/Object;)Z

    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->c:Landroid/content/Context;

    sget-wide v2, Lcom/tendcloud/tenddata/cx;->a:J

    invoke-static {v0, v2, v3}, Lcom/tendcloud/tenddata/cv;->a(Landroid/content/Context;J)V

    :cond_0
    :goto_0
    const-string v0, ""
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    :try_start_1
    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->c:Landroid/content/Context;

    invoke-static {v0}, Lcom/tendcloud/tenddata/cv;->c(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v0

    new-instance v1, Landroid/net/LocalServerSocket;

    invoke-direct {v1, v0}, Landroid/net/LocalServerSocket;-><init>(Ljava/lang/String;)V

    iput-object v1, p0, Lcom/tendcloud/tenddata/du;->d:Landroid/net/LocalServerSocket;

    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/tendcloud/tenddata/du;->h:Z

    new-instance v0, Ljava/lang/Thread;

    new-instance v1, Lcom/tendcloud/tenddata/du$a;

    const/4 v2, 0x0

    invoke-direct {v1, p0, v2}, Lcom/tendcloud/tenddata/du$a;-><init>(Lcom/tendcloud/tenddata/du;Lcom/tendcloud/tenddata/dv;)V

    invoke-direct {v0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    const-string v1, "t-read"

    invoke-virtual {v0, v1}, Ljava/lang/Thread;->setName(Ljava/lang/String;)V

    invoke-virtual {v0}, Ljava/lang/Thread;->start()V
    :try_end_1
    .catch Ljava/lang/Throwable; {:try_start_1 .. :try_end_1} :catch_0
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    :goto_1
    monitor-exit p0

    return-void

    :cond_1
    if-eqz v0, :cond_0

    :try_start_2
    const-string v1, "service-start"

    invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/tendcloud/tenddata/du;->c:Landroid/content/Context;

    sget-wide v2, Lcom/tendcloud/tenddata/cx;->a:J

    invoke-static {v0, v2, v3}, Lcom/tendcloud/tenddata/cv;->a(Landroid/content/Context;J)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    goto :goto_0

    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0

    :catch_0
    move-exception v0

    goto :goto_1
.end method
